package com.happy.zebra.admin.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.happy.zebra.admin.api.entity.LiveRoomEntity;
import com.happy.zebra.admin.mapper.LiveRoomMapper;
import com.shycloud.mido.common.core.util.R;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@AllArgsConstructor
@RequestMapping("/live")
public class LiveRoomController {
    
    private LiveRoomMapper liveRoomMapper;

    @GetMapping("/getRoomList")
    public R getRoomList() {
        QueryWrapper<LiveRoomEntity> queryWrapper = new QueryWrapper<>();
        return new R<>(liveRoomMapper.selectList(queryWrapper));
    }

    @GetMapping("/getRoomListByMemberId")
    public R getRoomListByMemberId(String memberId) {
        QueryWrapper<LiveRoomEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("member_id", memberId);
        return new R<>(liveRoomMapper.selectList(queryWrapper));
    }

    @PostMapping("/addRoom")
    public R addRoom(@RequestBody LiveRoomEntity room) {
        return new R<>(liveRoomMapper.insert(room));
    }
}
